﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

using System.Configuration;
namespace XMK.Tadong.Web.WebFileExplorer.WebServices
{
    public partial class Download1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            {
                string filePath = Server.MapPath("../DOC/help.doc"); //Request.QueryString["filePath"];//
                string fileName ="help.doc";// filePath.Substring(filePath.LastIndexOf('/') + 1); //客户端保存的文件名
               

                FileInfo fileInfo = new FileInfo(filePath);
                fileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);

                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();

                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();
            }

        }
    }
}